#$file = "./6/normalized_frma_normalcdf_gene_probeset.txt";
#open(BUFF,$file);
#$fi = "./6/genesumm_normalized_frma_normalcdf_gene_probeset.txt";
#open(WRBUFF,">$fi");
open(BUFF,"final_taqman_normalized.txt");
open(WRBUFF,">final__taqman_normalized.txt");
$line = <BUFF>;
print WRBUFF $line;
$num =0;
while($line = <BUFF>)
{
	chomp $line;
	$line =~ s/\n//g;
	$line =~ s/\r//g; 
	@array = split("\t",$line);
	$len = @array-1;
	if($hi{$array[$len]} eq "k")
	{
		
		@array1 = split("\t",$k{$array[10]});
#		$var = pop(@array);
		$var =shift(@array);
		chomp $var;
		$var =~ s/\n//g;
		$var =~ s/\t//g;
		$m{$var}++;
 #                shift(@array);
		for($y =0;$y<@array;$y++)
		{	
			$st[$y] = ($array1[$y] + $array[$y])/2;	
			
		}
		$k{$var} = join("\t",@st);
	}
	else
	{
		$hi{$array[$len]} = "k";
		
#		$var =  pop(@array);
		$var =shift(@array);
		chomp $var;
		$var =~ s/\n//g;
                $var =~ s/\t//g;
#		 shift(@array);
		$line = join("\t",@array);

		$k{$var} = $line;
		$m{$var} = 1;
		$i++; 
		$st_ar[$num] = $var;
		$num++;

	}
}
for($z=0;$z<@st_ar;$z++)
{
	#print WRBUFF $st_ar[$z]."\t".$k{$st_ar[$z]}."\t".$m{$st_ar[$z]}."\n";
	print WRBUFF $st_ar[$z]."\t".$k{$st_ar[$z]}."\n";
}
#system("dos2unix $fi");
